;
(function() {
	new Vue({
		el: '#cEnd',
		data: {
			flag: true,
			beginTime: '',
			endTime: '',
			orders: '#',
			columns: '#',
			pagetotal: 0,
			page: 1,
			limit: ['10'],
			pageCounts: [{name: '10', code: '10'}, {name: '15', code: '15'}, {name: '20', code: '20'}],
			modulesList: [],
			typelist: [],
			typeStatus: [],
			keyword: '',
			data: [],
			quanxian: JSON.parse(window.localStorage.getItem('permissions')),
			isValidateLt: [{
				name: '是',
				code: 'Y'
			}, {
				name: '否',
				code: 'N'
			}],
			isValidate: '#',
			copyUrl: ''
		},
		filters: {
			framtTime(time) {
				return hlDateUtil.formatDate(time, 'yyyy-MM-dd HH:mm:ss')
			},
			formatDate: function(time) {
				if (time === undefined) return '--'
				return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd')
			},
		},
		methods: {
			// 设置背景色
			addbgcolor(index) {
				let el = document.querySelectorAll('.house-two-tone');
				let el0 = document.querySelectorAll('.house-operate')
				el[index].classList.add('house-two-tone-hover')
				el0[index].classList.add('house-two-tone-hover')
			},
			//删除背景色
			removebgcolor(index) {
				let el = document.querySelectorAll('.house-two-tone');
				let el0 = document.querySelectorAll('.house-operate')
				el[index].classList.remove('house-two-tone-hover')
				el0[index].classList.remove('house-two-tone-hover')
			},
			//最后更新时间
			updateTime() {
				setTimeout(() => {
					this.getListData();
				}, 300)
				if (this.columns != 'UT') {
					this.columns = 'UT';
					this.orders = 'ASC';
					return
				}
				if (this.orders == 'ASC') {
					this.orders = 'DESC'
					return
				}
				if (this.orders == 'DESC') {
					this.orders = 'ASC'
					return
				}
			},
			//创建时间
			createTime() {
				setTimeout(() => {
					this.getListData();
				}, 300)
				if (this.columns != 'CT') {
					this.columns = 'CT';
					this.orders = 'ASC';
					return
				}
				if (this.orders == 'ASC') {
					this.orders = 'DESC'
					return
				}
				if (this.orders == 'DESC') {
					this.orders = 'ASC'
					return
				}
			},
			//有效时间
			etpTime() {
				setTimeout(() => {
					this.getListData();
				}, 300)
				if (this.columns != 'ETP') {
					this.columns = 'ETP';
					this.orders = 'ASC';
					return
				}
				if (this.orders == 'ASC') {
					this.orders = 'DESC'
					return
				}
				if (this.orders == 'DESC') {
					this.orders = 'ASC'
					return
				}
			},
			//新建信息
			createInfo() {
				hlUrlUtil.goTo('activity_welfare_create', {
					ddtab: true
				}, true)
			},
			//编辑信息
			editorPerview(item) {
				hlUrlUtil.goTo('activityWelfareEdit', {
					ddtab: true,
					id: item.activityId,
					clear: true
				}, true)
			},
			//启用停用
			isValidateStatus (item) {
				hlhttp.put({
					url: 'portal/set_activity_status',
					data: {activity_id: item.activityId, status: item.status == 'Y' ? 'N' : 'Y'},
					success: () => {
						hl.toast('操作成功')
						this.getListData()
					}
				})
			},
			//预览
			prevew (item) {
				hlUrlUtil.goTo('jwkprevew', {
					ddtab: true,
					id: item.activityId,
					clear: true
				}, true)
			},
			//删除
			del (item) {
				hllayer.confirm('是否删除此条？', () => {
				   hlhttp.delete({
				   	url: 'portal/activity?activity_id=' + item.activityId,
				   	success: () => {
				   		this.getListData()
				   	}
				   })
				})

			},
			//获取状态
			gettypelist() {
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'CSTM_JWK',
						config_name: 'CSTM_JWK_ACTVT_TYPE'
					},
					success: (data) => {
						this.typelist = hlArrayUtil.replaceData(data, [{key: 'dictName', rKey: 'name'}, {key: 'dictCode', rKey: 'code'}]);
					}
				})
			},
			eventType(arr) {
				this.typeStatus = [arr[0].code]
			},
			//展示数量
			eventPage(arr) {
				this.limit = [arr[0].code]
				this.getListData()
			},
			//重置
			reset() {
				this.keyword = '';
				this.page = 1;
				this.limit = ['10'];
				this.beginTime = '';
				this.endTime = '';
				this.orders = '#';
				this.columns = '#';
				this.typeStatus = [];
				this.getListData()
			},
			getListData0() {
				this.page = 1;
				this.getListData()
			},
			//获取列表
			getListData() {
				hlhttp.get({
					url: 'portal/activitys',
					data: {
						"keyword": this.keyword || '#',
						"activity_type": this.typeStatus.length ? this.typeStatus[0] : '#',
						"begin_time": this.beginTime || '#',
						"end_time": this.endTime || '#',
						"orders": this.orders,
						"columns": this.columns,
						"page": this.page,
						"limit": this.limit[0]
					},
					success: (data) => {
						this.data = data;
						$("#page").initPage(data.totalPage, this.page, (n) => {
							if (this.page == n) {
								return
							}
							this.page = n;
							this.getListData();
						});
					}
				})
			},
			//复制url
			copyURL (item) {
				let functionCate;
				if (item.activityType == 'JWK_ACTVT_FL') {
					//福利
					functionCate = 'COPYURL_JWK_FL'
				}
				if (item.activityType == 'JWK_ACTVT_HD') {
					//活动
					functionCate = 'COPYURL_JWK_HD'
				}

				hlhttp.get({
					url: 'configure/copy_url',
					data: {
						function_cate: functionCate,
						params: item.activityId
					},
					async:false,
					success: (data) => {
						var Url = document.getElementById("copyInput");
						Url.value = data.copyUrl;
					}
				})

			},
			copyss () {
				var Url = document.getElementById("copyInput");
				Url.select(); // 选择对象
				document.execCommand("Copy"); // 执行浏览器复制命令
				hl.toast('复制成功')
			}
		},
		created() {
			hlSelectUi()
		},
		mounted() {
			this.gettypelist()
			this.getListData()
		}
	})

}())
